package com.ccnu.sb.controller;

import com.ccnu.sb.dao.pojo.TCust;
import com.ccnu.sb.database.RMQL;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/database")
public class DatabaseController {
    private static Logger log = LogManager.getLogger();

    @Autowired
    private RMQL rMSQL;

    @RequestMapping("/query")
    public TCust check(@RequestBody Map<String, Object> maps) {
        log.info(maps.toString());
        return rMSQL.query((String) maps.get("cust_no"));
    }

    @RequestMapping("/insert")
    @ResponseBody
    public TCust insert(@RequestBody Map<String, String> maps) {
        log.info(maps.toString());
        TCust cust = new TCust();
//        TODO 增加用户信息
        rMSQL.insert(cust);
        return cust;
    }
}
